package com.plian.system.controller.sys.message;

import com.plian.system.annotation.LogOperation;
import com.plian.system.entity.sys.Message;
import com.plian.system.model.ListResult;
import com.plian.system.model.R;
import com.plian.system.mybatis.support.Query;
import com.plian.system.service.sys.message.IMessageService;
import com.plian.system.task.message.MessageTask;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @description:
 * @author: gangan
 * @create: 2021-01-13 18:18
 */
@RestController
@RequestMapping(value = "api/message")
@AllArgsConstructor
public class MessageController {

    private IMessageService messageService;

    private MessageTask messageTask;

    @PostMapping("/list")
    @LogOperation("消息-查询")
    public ListResult<Message> list(@RequestBody Query query){
        return messageService.list(query);
    }

    @PostMapping("/{id}/ignore")
    @LogOperation("消息-忽略")
    public R ignore(@PathVariable Integer id){
        return R.status(messageService.ignore(id));
    }

    @GetMapping("/init")
    @LogOperation("消息-定时任务init")
    public void init(){
        messageTask.start();
    }
}
